<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:s="http://jboss.org/schema/seam/taglib"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:rich="http://richfaces.org/rich"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:richext="http://java.sun.com/jsf/composite/richext"
  template="../WEB-INF/template/template_2x.xhtml">

  <ui:define name="page_title">#{msgs['jsf.Projects']}</ui:define>

  <ui:define name="right_content">
    <rich:panel id="loggedIn" rendered="#{identity.loggedIn}">
      <f:facet name="header">#{msgs['jsf.Actions']}</f:facet>
      <s:link id="createProjectLink" styleClass="action_link"
        rendered="#{s:hasPermission(projectHome.instance, 'insert')}"
        value="#{msgs['jsf.NewProject.Label']}"
        view="/project/create_project.xhtml"
        propagation="none"/>
      <h:outputLink id="exportTMXAllLink" styleClass="action_link"
        rendered="#{s:hasRole('admin')}"
        onclick="return confirm('#{msgs['jsf.ConfirmExportTMXAll']}')"
        value="#{request.contextPath}/rest/tm/all">
        <h:outputText value="#{msgs['jsf.ExportTMXAll']}"/>
      </h:outputLink>
    </rich:panel>
  </ui:define>

  <ui:define name="center_content">
    <s:decorate id="main_content">
      <s:fragment rendered="#{projectAction.getEmpty()}">
        <h:outputText value="#{msgs['jsf.NoProjectExists']}"/>
      </s:fragment>
      <s:fragment rendered="#{!projectAction.getEmpty()}">
        <h:form id="form">

          <div style="text-align: center">
            <rich:dataScroller renderIfSinglePage="false" for="projectList"
              maxPages="10"
              page="#{projectAction.projectPagedListDataModel.scrollerPage}"
              id="scroller" render="sc2" fastControls="hide">
              <f:facet name="first">
                <h:outputText value="" styleClass="icon-to-start"/>
              </f:facet>
              <f:facet name="previous">
                <h:outputText value="" styleClass="icon-left-open"/>
              </f:facet>
              <f:facet name="next">
                <h:outputText value="" styleClass="icon-right-open-1"/>
              </f:facet>
              <f:facet name="fastforward">
                <h:outputText value="" styleClass="icon-fast-fw-1"/>
              </f:facet>
              <f:facet name="last">
                <h:outputText value="" styleClass="icon-to-end"/>
              </f:facet>

              <f:facet name="first_disabled">
                <h:outputText value="" styleClass="icon-to-start"/>
              </f:facet>
              <f:facet name="previous_disabled">
                <h:outputText value="" styleClass="icon-left-open"/>
              </f:facet>
              <f:facet name="next_disabled">
                <h:outputText value="" styleClass="icon-right-open-1"/>
              </f:facet>
              <f:facet name="fastforward_disabled">
                <h:outputText value="" styleClass="icon-fast-fw-1"/>
              </f:facet>
              <f:facet name="last_disabled">
                <h:outputText value="" styleClass="icon-to-end"/>
              </f:facet>
            </rich:dataScroller>
          </div>

          <s:div styleClass="float-right">
            <a4j:region>
              <h:selectBooleanCheckbox
                title="#{msgs['jsf.FilterActiveProjects']}"
                value="#{projectAction.showActive}">
                <a4j:ajax event="change" render="projectList"/>
              </h:selectBooleanCheckbox>
              <h:outputText value="#{msgs['jsf.Active']}"/>

              <h:outputText value="&#160;"/>
              <h:selectBooleanCheckbox
                title="#{msgs['jsf.FilterReadOnlyProjects']}"
                value="#{projectAction.showReadOnly}">
                <a4j:ajax event="change" render="projectList"/>
              </h:selectBooleanCheckbox>
              <h:outputText value="#{msgs['jsf.ReadOnly']}"/>

              <h:outputText value="&#160;"/>
              <s:fragment
                rendered="#{s:hasPermission('HProject','view-obsolete')}">
                <h:selectBooleanCheckbox
                  title="#{msgs['jsf.FilterObsoleteProjects']}"
                  value="#{projectAction.showObsolete}">
                  <a4j:ajax event="change" render="projectList"/>
                </h:selectBooleanCheckbox>
                <h:outputText value="#{msgs['jsf.Obsolete']}"/>
              </s:fragment>
            </a4j:region>
          </s:div>
          <br/>
          <rich:dataTable id="projectList"
            rows="#{projectAction.projectPagedListDataModel.pageSize}"
            value="#{projectAction.projectPagedListDataModel}" var="project">
            <rich:column width="270px" sortBy="#{project.name}">
              <f:facet name="header">#{msgs['jsf.ProjectName']}
                <richext:columnSorter/>
              </f:facet>

              <s:link id="project" styleClass="table_link"
                value="#{project.name}" propagation="none"
                view="/project/project.xhtml"
                rendered="#{project.status == 'ACTIVE'}">
                <f:param name="slug" value="#{project.slug}"/>
              </s:link>
              <s:link id="readonlyProject" styleClass="table_link readonly_link"
                value="#{project.name}" propagation="none"
                view="/project/project.xhtml"
                rendered="#{project.status == 'READONLY'}">
                <f:param name="slug" value="#{project.slug}"/>
              </s:link>
              <s:link id="obsoleteProject" styleClass="table_link obsolete_link"
                value="#{project.name}" propagation="none"
                view="/project/project.xhtml"
                rendered="#{project.status == 'OBSOLETE'}">
                <f:param name="slug" value="#{project.slug}"/>
              </s:link>
            </rich:column>
            <rich:column width="270px">
              <f:facet name="header">#{msgs['jsf.Description']}</f:facet>
              <h:outputText value="#{project.description}"/>
            </rich:column>
            <rich:column sortBy="#{project.creationDate}" width="auto">
              <f:facet name="header">#{msgs['jsf.CreationDate']}
                <richext:columnSorter/></f:facet>
              <h:outputText value="#{project.creationDate}">
                <f:convertDateTime type="date" dateStyle="default"/>
              </h:outputText>
            </rich:column>

            <rich:column styleClass="centered" width="60px"
              sortBy="#{project.status}">
              <f:facet name="header">#{msgs['jsf.Status']}
                <richext:columnSorter/></f:facet>
              <h:outputText value="#{msgs[project.status.messageKey]}"/>
            </rich:column>
          </rich:dataTable>

          <div style="text-align: center">
            <rich:dataScroller align="center" for="projectList" maxPages="10"
              page="#{projectAction.projectPagedListDataModel.scrollerPage}"
              id="sc2" render="scroller"
              fastControls="hide" renderIfSinglePage="false">
              <f:facet name="first">
                <h:outputText value="" styleClass="icon-to-start"/>
              </f:facet>
              <f:facet name="previous">
                <h:outputText value="" styleClass="icon-left-open"/>
              </f:facet>
              <f:facet name="next">
                <h:outputText value="" styleClass="icon-right-open-1"/>
              </f:facet>
              <f:facet name="last">
                <h:outputText value="" styleClass="icon-to-end"/>
              </f:facet>

              <f:facet name="first_disabled">
                <h:outputText value="" styleClass="icon-to-start"/>
              </f:facet>
              <f:facet name="previous_disabled">
                <h:outputText value="" styleClass="icon-left-open"/>
              </f:facet>
              <f:facet name="next_disabled">
                <h:outputText value="" styleClass="icon-right-open-1"/>
              </f:facet>
              <f:facet name="last_disabled">
                <h:outputText value="" styleClass="icon-to-end"/>
              </f:facet>
            </rich:dataScroller>
          </div>
        </h:form>
      </s:fragment>
    </s:decorate>
  </ui:define>

</ui:composition>
